package com.itheima.service.cargo.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.cargo.ShippingDao;
import com.itheima.domain.cargo.Shipping;
import com.itheima.domain.cargo.ShippingExample;
import com.itheima.service.cargo.ShippingService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ShippingServiceImpl implements ShippingService {
    @Autowired
    private ShippingDao shippingDao;

    @Override
    public Shipping findById(String id) {
        return shippingDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(Shipping shipping) {
        shippingDao.insert(shipping);
    }

    @Override
    public void update(Shipping shipping) {

    }

    @Override
    public void delete(String id) {
        shippingDao.deleteByPrimaryKey(id);
    }

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, ShippingExample example) {
        //设置分页参数
        PageHelper.startPage(pageNum,pageSize);
        //查询全部
        List<Shipping> list = shippingDao.selectByExample(example);
        //构造返回值
        return new PageInfo(list);
    }
}
